package com.sunny.hp.common.util;


// Source File Name:   CmnUtil.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;






/********************************************************************************
 * <PRE> * 시스템 정보글 가져온다. *
 * 1. Project		: BEMS2.1
 * 2. Package	: com.ncomz.nzeip.common.util
 * 3. FileName	: SystemUtil.java
 * 4. 작성자		: P044826
 * 5. 작성일		: 2013. 11. 15. 오후 2:36:31
 * 6. 설명			:
 * </PRE>
 ********************************************************************************/

/********************************************************************************
 * <PRE> * 프로그램 정보 *
 * 1. Project		: BEMS2.1
 * 2. Package	: com.ncomz.nzeip.common.util
 * 3. FileName	: SystemUtil.java
 * 4. 작성자		: P044826
 * 5. 작성일		: 2013. 11. 15. 오후 2:39:14
 * 6. 설명			:
 * </PRE>
 ********************************************************************************/

public  final  class SystemUtil
{


	static String TAG = "UserMessageUtil";

	static Logger logger = LogUtil.getLogger(TAG);//

	public SystemUtil()
	{
		super();
	}


	/**<xmp>
	 *      Method : getSystemSiteCd
	 *      ����Ʈ �ڵ� ��������
	 *  </xmp>
	 * @param   site_cd String  : �����ڵ�
	 * @return long
	 * @author
	 * @see
	 */
	public static String getSystemSiteCd(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_site_cd = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_site_cd" )!=null)
					system_attr_site_cd = req.getSession().getAttribute("system_attr_site_cd" ).toString();
			}

			if(system_attr_site_cd==null||system_attr_site_cd.equals("")){
				system_attr_site_cd = PropertiesUtil.getMessage("SPWEB.BASE.SITE_CD");
			}
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemSiteCd <<Exception>> : "+e.toString() );
			system_attr_site_cd = e.getMessage() ;
		}

		return system_attr_site_cd;
	}


	/**********************************************************************
	 * <PRE> * 사용자 IP 받아오기 *
	 * 1. MethodName	: getSystemUserIp
	 * 2. ClassName		: SystemUtil
	 * 3. 작성자			: P044826
	 * 4. 작성일			: 2013. 11. 15. 오후 2:38:47
	 * 5. 설명				:
	 * </PRE>
	 * 		@return String
	 * 		@param req
	 * 		@param res
	 * 		@return
	 **********************************************************************/
	public static String getSystemUserIp(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_user_ip = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_user_ip" )!=null)
					system_attr_user_ip = req.getSession().getAttribute("system_attr_user_ip" ).toString();
			}
			if(system_attr_user_ip==null||system_attr_user_ip.equals("")){
				system_attr_user_ip = req.getHeader("Proxy-Client-IP") == null ?
						req.getRemoteAddr() : req.getHeader("Proxy-Client-IP").toString();
			}
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemUserIp <<Exception>> : "+e.toString() );
			system_attr_user_ip = e.getMessage() ;
		}
		return system_attr_user_ip;
	}



	/**********************************************************************
	 * <PRE> * 시스템 사용자 명 가져오기  *
	 * 1. MethodName	: getSystemUserNm
	 * 2. ClassName		: SystemUtil
	 * 3. 작성자			: P044826
	 * 4. 작성일			: 2013. 11. 15. 오후 2:39:17
	 * 5. 설명				:
	 * </PRE>
	 * 		@return String
	 * 		@param req
	 * 		@param res
	 * 		@return
	 **********************************************************************/
	public static String getSystemUserNm(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_user_nm = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_user_nm" )!=null)
					system_attr_user_nm = req.getSession().getAttribute("system_attr_user_nm" ).toString();
			}
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemUserNm <<Exception>> : "+e.toString() );
			system_attr_user_nm = e.getMessage() ;
		}

		return system_attr_user_nm;
	}


	/**********************************************************************
	 * <PRE> * 시스템 사용자 아이디  *
	 * 1. MethodName	: getSystemUserId
	 * 2. ClassName		: SystemUtil
	 * 3. 작성자			: P044826
	 * 4. 작성일			: 2013. 11. 15. 오후 2:39:43
	 * 5. 설명				:
	 * </PRE>
	 * 		@return String
	 * 		@param req
	 * 		@param res
	 * 		@return
	 **********************************************************************/
	public static String getSystemUserId(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_user_id = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_user_id" )!=null)
					system_attr_user_id = req.getSession().getAttribute("system_attr_user_id" ).toString();
			}
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemUserId <<Exception>> : "+e.toString() );
			system_attr_user_id = e.getMessage() ;
		}
		return system_attr_user_id;
	}

	/**********************************************************************
	 * <PRE> * 사용자 그룹 정보 받아오기 *
	 * 1. MethodName	: getSystemUserAuthGroupId
	 * 2. ClassName		: SystemUtil
	 * 3. 작성자			: P044826
	 * 4. 작성일			: 2013. 11. 15. 오후 2:40:13
	 * 5. 설명				:
	 * </PRE>
	 * 		@return String
	 * 		@param req
	 * 		@param res
	 * 		@return
	 **********************************************************************/
	public static String getSystemUserAuthGroupId(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_auth_group_id = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_auth_group_id" )!=null)
					system_attr_auth_group_id = req.getSession().getAttribute("system_attr_auth_group_id" ).toString();
			}
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemUserAuthGroupId <<Exception>> : "+e.toString() );
			system_attr_auth_group_id = e.getMessage() ;
		}
		return system_attr_auth_group_id;
	}
	/**********************************************************************
	 * <PRE> * 사용자 이메일 정보 받아오기 *
	 * 1. MethodName	: getSystemUserEmail
	 * 2. ClassName		: SystemUtil
	 * 3. 작성자			: P044826
	 * 4. 작성일			: 2013. 11. 15. 오후 2:40:29
	 * 5. 설명				:
	 * </PRE>
	 * 		@return String
	 * 		@param req
	 * 		@param res
	 * 		@return
	 **********************************************************************/
	public static String getSystemUserEmail(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_user_email = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_email" )!=null)
					system_attr_user_email = req.getSession().getAttribute("system_attr_email" ).toString();
			}
			//            if(system_attr_user_email==null||system_attr_user_email.equals("")){
			////            	system_attr_user_email = "";//PropertyHandler.getProperty("SPWEB.BASE.DEFAULT.USER_ID");
			//            }
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemUserEmail <<Exception>> : "+e.toString() );
			system_attr_user_email = e.getMessage() ;
		}
		return system_attr_user_email;
	}
	/**<xmp>
	 *      Method : getSystemContextPath
	 *      ContextPath ��������
	 *  </xmp>
	 * @param
	 * @return long
	 * @author
	 * @see
	 */
	public static String getSystemContextPath(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_context_path = "";
		try{
			system_attr_context_path = req.getContextPath();
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemContextPath <<Exception>> : "+e.toString() );
			system_attr_context_path = e.getMessage() ;
		}

		return system_attr_context_path;
	}
	/** BaseConstants.FRONT_SYS : front_sys , BaseConstants.BACK_SYS : BaseConstants.back_sys ,DASH_SYS : dash_sys */
	public static String getSystemSystemGb(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_sys_gb = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_sys_gb" )!=null)
					system_attr_sys_gb = req.getSession().getAttribute("system_attr_sys_gb" ).toString();
			}
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemSystemGb <<Exception>> : "+e.toString() );
			system_attr_sys_gb = e.getMessage() ;
		}

		return system_attr_sys_gb;
	}
	public static String getSystemAuthGroupId(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_sys_gb = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_auth_group_id" )!=null)
					system_attr_sys_gb = req.getSession().getAttribute("system_attr_auth_group_id" ).toString();
			}
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemAuthGroupId <<Exception>> : "+e.toString() );
			system_attr_sys_gb = e.getMessage() ;
		}

		return system_attr_sys_gb;
	}

	/**********************************************************************
	 * <PRE> * 메소드 정보 *
	 * 1. MethodName	: getSystemAuthId
	 * 2. ClassName		: SystemUtil
	 * 3. 작성자			: P044826
	 * 4. 작성일			: 2013. 11. 15. 오후 2:41:07
	 * 5. 설명				:
	 * </PRE>
	 * 		@return String
	 * 		@param req
	 * 		@param res
	 * 		@return
	**********************************************************************/
	public static String getSystemAuthId(HttpServletRequest req
			,HttpServletResponse res)
	{
		String system_attr_sys_gb = "";
		try{
			if(req.getSession()!=null){
				if(req.getSession().getAttribute("system_attr_auth_id" )!=null)
					system_attr_sys_gb = req.getSession().getAttribute("system_attr_auth_id" ).toString();
			}
		}
		catch(Exception e)
		{
			logger.error(TAG+" getSystemAuthId <<Exception>> : "+e.toString() );
			system_attr_sys_gb = e.getMessage() ;
		}

		return system_attr_sys_gb;
	}





}





